package net.toocruel.iqismart.dao.support;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;

public class TipaskPhysicalNamingStrategyStandardImpl extends PhysicalNamingStrategyStandardImpl {
    private SpringPhysicalNamingStrategy springPhysicalNamingStrategy = new SpringPhysicalNamingStrategy();
    @Override
    public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment context) {
        return super.toPhysicalCatalogName(name, context);
    }

    @Override
    public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment context) {
        return super.toPhysicalSchemaName(name, context);
    }

    @Override
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
        if(name!=null){
//            return Identifier.toIdentifier(name.toString().toLowerCase());
            return springPhysicalNamingStrategy.toPhysicalTableName(name,context);
        }else{
            return super.toPhysicalTableName(name,context);
        }
    }

    @Override
    public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment context) {
        return super.toPhysicalSequenceName(name, context);
    }

    @Override
    public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) {
        return super.toPhysicalColumnName(name, context);
    }
}
